import 'package:app/common/tool.dart';
import 'package:app/components/base_scaffold_appbar.dart';
import 'package:app/pages/login_modules/forget_password_module/forget_password_controller.dart';
import 'package:app/utils/search_module.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';

import '../../../common/colors.dart';
import '../../../components/countdown_button_page.dart';
import '../../../components/gradient_button.dart';
import '../../../utils/phone_inputformatter.dart';
import '../../../utils/hexcolor.dart';

class ForgetPasswordView extends GetView<ForgetPasswordController>{
  
  
  ForgetPasswordController controller = Get.put(ForgetPasswordController());

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: BaseAppBar(
        preferredSize: Size(Get.width, AppTool.appBarHEIGHT),
        child: Text('忘记密码'),
      ),
      // AppBar(
      //   title: Text('忘记密码',style: TextStyle(color: Colors.black),),
      //   leading: IconButton(onPressed: () {
      //     Get.back();
      //   },icon: Image.asset('images/leftarr.png',width:15,height: 15,),),
      // ),
      body: GetBuilder<ForgetPasswordController>(builder: (_){
        return GestureDetector(
          onTap: (){
            SearchModule.closeKeyboard(context);
          },
          child: Container(
            child: ListView(
              children: [
                Center(
                  child: Container(
                      margin: EdgeInsets.only(top: 20, left: 15, right: 10),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Container(

                            // margin: EdgeInsets.only(left: 15),
                              width: 200,
                              child: Row(
                                children: [
                                  GestureDetector(
                                    onTap: () async {
                                      // var data = await  Get.to(SelectOptionsPage());
                                      // if(data!=null){
                                      //   options = data;
                                      //   setState(() {
                                      //
                                      //   });
                                      // }

                                    },
                                    child: Container(
                                      margin: EdgeInsets.only(top: 2),
                                      // color: Colors.red,
                                      child: Text(
                                        '${controller.options}', style: TextStyle(color: Theme
                                          .of(context)
                                          .primaryColor),),
                                    ),
                                  ),
                                  // TextButton(onPressed: (){
                                  //   Get.to(SelectOptionsPage());
                                  //
                                  // }, child: Text('+86')),

                                  Container(
                                    padding: const EdgeInsets.only(left: 5),
                                    width: 160,
                                    child: TextField(
                                      autofocus: true,
                                      controller: controller.mobileTextController,
                                      keyboardType: TextInputType.phone,
                                      style: TextStyle(
                                          fontSize: 16, color: HexColor('#333333')),
                                      inputFormatters: <TextInputFormatter>[
                                        LengthLimitingTextInputFormatter(13), //限制长度
                                        phoneInputFormatter(),
                                      ],
                                      decoration: InputDecoration(
                                        hintText: '请输入手机号码'.tr,
                                        hintStyle: TextStyle(fontSize: 16,
                                            color: HexColor('#BBBBBB')),
                                        border: InputBorder.none,
                                        // prefixIcon: Icon(Icons.phone_android,size: 15,),
                                      ),
                                    ),
                                  )
                                ],
                              )
                          ),
                          CountdownButton(controller.mobileTextController,type: 'pass',),
                        ],
                      )
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(left: 15,right: 15),
                  color: AppColor.lineColor,
                  width: Get.width,
                  height: 1,
                ),
                Center(
                  child: Container(
                    alignment: Alignment.center,
                    // color: Colors.red,
                    // margin: EdgeInsets.only(left: 25),
                    margin: EdgeInsets.only(left: 15,right: 15,top: 15),
                    child:Row(
                      children: [
                        Image.asset('images/yzm_icon.png',width: 16,height: 16,),
                        Container(
                          // color: Colors.yellow,
                          width: Get.width-60,
                          height: 40,
                          margin: EdgeInsets.only(left: 10),
                          child:  TextField(
                            inputFormatters: <TextInputFormatter>[
                              LengthLimitingTextInputFormatter(6)//限制长度
                            ],
                            controller: controller.codeTextController,
                            style: TextStyle(fontSize: 16, color: HexColor('#333333')),
                            decoration: InputDecoration(
                              hintText: '请输入验证码'.tr,
                              hintStyle: TextStyle(fontSize: 16, color: HexColor(
                                  '#BBBBBB')),
                              border: InputBorder.none,
                              // prefixIcon: Image.asset(A.assets_pwd),
                            ),
                          ),
                        )
                      ],
                    ),
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(left: 15,right: 15),
                  color: AppColor.lineColor,
                  width: Get.width,
                  height: 1,
                ),
                Center(
                  child: Container(
                    // color: Colors.red,
                    margin: EdgeInsets.only(top: 15, right: 15, left: 15),
                    child: Container(
                      // margin: EdgeInsets.only(left: 25),
                      child: Row(
                        children: [
                          Image.asset('images/pass_icon.png',width: 16,height: 16,),
                          Container(

                            margin: EdgeInsets.only(left: 5),
                            height: 40,
                            width: Get.width-60,
                            child: TextField(
                              obscureText: true,
                              inputFormatters: <TextInputFormatter>[
                                LengthLimitingTextInputFormatter(16)//限制长度
                              ],
                              controller: controller.passWordController,
                              style: TextStyle(fontSize: 16, color: HexColor('#333333')),
                              decoration: InputDecoration(
                                hintText: '请输入新密码'.tr,
                                hintStyle: TextStyle(fontSize: 16, color: HexColor(
                                    '#BBBBBB')),
                                border: InputBorder.none,
                                // prefixIcon: Image.asset(A.assets_pwd),
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(left: 15,right: 15),
                  height: 1,
                  color: AppColor.lineColor,
                ),

                Center(
                  child: Container(
                    // color: Colors.red,
                    margin: EdgeInsets.only(top: 15, right: 15, left: 15),
                    child: Container(
                      // margin: EdgeInsets.only(left: 25),
                      child: Row(
                        children: [
                          Image.asset('images/pass_icon.png',width: 16,height: 16,),
                          Container(
                            height: 40,
                            width: Get.width-60,

                            margin: EdgeInsets.only(left: 5),
                            child: TextField(
                              obscureText: true,
                              inputFormatters: <TextInputFormatter>[
                                LengthLimitingTextInputFormatter(16)//限制长度
                              ],
                              controller: controller.passWordControlle1,
                              style: TextStyle(fontSize: 16, color: HexColor('#333333')),
                              decoration: InputDecoration(
                                hintText: '确认密码'.tr,
                                hintStyle: TextStyle(fontSize: 16, color: HexColor(
                                    '#BBBBBB')),
                                border: InputBorder.none,
                                // prefixIcon: Image.asset(A.assets_pwd),
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(left: 15,right: 15),
                  height: 1,
                  color: AppColor.lineColor,
                ),
                SizedBox(height: 15,),
                Center(
                  child: Text('8-16位密码，须包含数字、字母、符号中至少2位元素',style: TextStyle(fontSize: 12,
                      color: AppColor.smallTextColor
                  ),),
                ),

                // Container(
                //   padding: EdgeInsets.only(left: 25, top: 15, right: 25),
                //   child: Row(
                //     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                //     children: [
                //       GestureDetector(
                //
                //         child: Text(
                //           '手势登录'.tr, style: TextStyle(fontSize: 14, color: HexColor(
                //             '#2A39E1')),),
                //         onTap: () {
                //           // Get.to(GesturePasswordWidgetDemo());
                //         },
                //       ),
                //       GestureDetector(
                //
                //         child: Text(
                //           '人脸登录'.tr, style: TextStyle(fontSize: 14, color: HexColor(
                //             '#2A39E1')),),
                //         onTap: () {
                //           // Get.to(FaceLoginPage());
                //         },
                //       ),
                //     ],
                //   ),
                // ),

                Container(
                  margin: EdgeInsets.only(top: 72, right: 15, left: 15),
                  width: Get.width,
                  height: 45,
                  child:GradientButton(
                    child: Text('修改密码'),
                    onPressed: (){
                      controller.tapClickForget();
                    },
                    borderRadius: BorderRadius.all(Radius.circular(20)),
                  ),
                  // MaterialButton(
                  //   elevation: 0,
                  //   shape: RoundedRectangleBorder(
                  //     borderRadius: BorderRadius.circular(22),
                  //   ),
                  //   color: Theme
                  //       .of(context)
                  //       .primaryColor,
                  //   onPressed: () async {
                  //     controller.tapClickForget();
                  //
                  //     // requestDataWithChangePassword(_mobileTextController.text,
                  //     //     _passWordController.text, _codeTextController.text);
                  //   },
                  //   child: Text('修改密码'.tr, style: TextStyle(color: Colors.white),),
                  // ),
                ),
              ],
            ),
          ),
        );
      }),
    );
  }
  
}